package edu.fdzc.learn.service.impl;


import edu.fdzc.learn.entity.Comments;
import edu.fdzc.learn.mapper.CommentMapper;
import edu.fdzc.learn.service.CommentService;
import edu.fdzc.learn.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public void insert(Comments comment) {
        comment.setCreatedAt(LocalDateTime.now());
        commentMapper.insertComment(comment);
    }

    @Override
    public Comments findById(int id) {
        return commentMapper.findById(id);
    }

    @Override
    public void delete(int id) {
        commentMapper.delete(id);
    }

    @Override
    public List<Comments> findAll(int id) {
        List<Comments> list = commentMapper.fandall(id);
        return list;
    }
}
